@extends('admin::layouts.master')
@section('content')
    <div class="col-lg-12">
        <div class="card card-border-color card-border-color-primary">
            <div class="card-header">
                商品操作
            </div>
            <div class="card-body">
                <div class="col-lg-12">
                    <div class="card card-table">
                        <div class="card-header">
                            <a href="{{route('goods.index')}}" class="btn btn-space btn-primary">商品列表</a>
                            <a href="{{route('goods.create')}}" class="btn btn-space btn-success">添加商品</a>
                        </div>
                        <div class="card-body">
                            <table class="table">
                                <thead>
                                <tr>
                                    <th style="">商品编号</th>
                                    <th style="">商品名称</th>
                                    <th style="">商品价格</th>
                                    {{--<th>商品描述</th>--}}
                                    <th>商品缩略图</th>
                                    <th>商品访问量</th>
                                    <th class="actions">操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($goods as $v)
                                <tr>
                                    <td>{{$v['id']}}</td>
                                    <td>{{$v['gname']}}</td>
                                    <td>{{$v['price']}}</td>
                                    {{--<td>{{$v['miaoshu']}}</td>--}}
                                    {{--把图片展示出来，数据库里面存的是json数据，需要转换成php的数组形式，用json_decode()方法转数组，然后循环输出就可以了--}}
                                    <td>@foreach(json_decode($v['pics'],true) as $vv) <img src="{{$vv['url']}}" alt="" style="width: 40px"> @endforeach</td>
                                    <td>{{$v['click']}}</td>
                                    <td class="actions">
                                        <div class="btn-group btn-space">
                                            <a href="{{route('goods.edit',$v['id'])}}" class="btn btn-space btn-primary">
                                                编辑
                                            </a>
                                            <form action="{{route('goods.destroy',$v['id'])}}" method="post">
                                                @csrf
                                                @method('DELETE')
                                                <button  class="btn btn-space btn-danger">删除</button>
                                            </form>
                                            <a href="{{route('shop',$v['id'])}}" class="btn btn-space btn-success">查看货品情况</a>
                                        </div>
                                    </td>
                                </tr>
                                @endforeach
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div>
            {{$goods->links()}}
        </div>
    </div>
    @endsection